home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / libbonobo-2.0 / bonobo / bonobo-exception.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-01-09  |  4.0 KB  |  119 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
  2. /*
  3.  * bonobo-exception.c: a generic exception -> user string converter.
  4.  *
  5.  * Authors:
  6.  *   Michael Meeks (michael@helixcode.com)
  7.  *
  8.  * Copyright 2000 Helix Code, Inc.
  9.  */
  10. #ifndef _BONOBO_EXCEPTION_H_
  11. #define _BONOBO_EXCEPTION_H_
  12.  
  13. #include <glib.h>
  14. #include <bonobo/Bonobo.h>
  15.  
  16. #define bonobo_exception_set(opt_ev,repo_id) G_STMT_START{                  \
  17.      if (opt_ev) {                                                          \
  18.          CORBA_exception_set (opt_ev, CORBA_USER_EXCEPTION, repo_id, NULL); \
  19.      } else {                                                               \
  20.      g_log (G_LOG_DOMAIN,                            \
  21.         G_LOG_LEVEL_CRITICAL,                        \
  22.         "file %s: line %d: bonobo exception: `%s'",                 \
  23.         __FILE__,                            \
  24.         __LINE__,                            \
  25.         bonobo_exception_repoid_to_text (repo_id));                 \
  26.      } }G_STMT_END
  27.  
  28. #ifdef G_DISABLE_CHECKS
  29.  
  30. #define bonobo_return_if_fail(expr,opt_ev) G_STMT_START{        \
  31.      if (!(expr)) {                            \
  32.          if (opt_ev)                                                    \
  33.          CORBA_exception_set (opt_ev, CORBA_USER_EXCEPTION,         \
  34.                   ex_Bonobo_BadArg, NULL);              \
  35.          return;                                                        \
  36.      };    }G_STMT_END
  37.  
  38. #define bonobo_return_val_if_fail(expr,val,opt_ev) G_STMT_START{    \
  39.      if (!(expr)) {                            \
  40.          if (opt_ev)                                                    \
  41.          CORBA_exception_set (opt_ev, CORBA_USER_EXCEPTION,         \
  42.                   ex_Bonobo_BadArg, NULL);              \
  43.          return val;                                                    \
  44.      };    }G_STMT_END
  45.  
  46. #else /* !G_DISABLE_CHECKS */
  47. #define bonobo_return_if_fail(expr,opt_ev) G_STMT_START{        \
  48.      if (!(expr)) {                            \
  49.          if (opt_ev)                                                    \
  50.          CORBA_exception_set (opt_ev, CORBA_USER_EXCEPTION,         \
  51.                   ex_Bonobo_BadArg, NULL);              \
  52.      g_log (G_LOG_DOMAIN,                        \
  53.         G_LOG_LEVEL_CRITICAL,                    \
  54.         "file %s: line %d (%s): assertion `%s' failed.",    \
  55.         __FILE__,                        \
  56.         __LINE__,                        \
  57.         G_GNUC_PRETTY_FUNCTION,                    \
  58.         #expr);                            \
  59.          return;                                                        \
  60.      };    }G_STMT_END
  61.          
  62. #define bonobo_return_val_if_fail(expr,val,opt_ev) G_STMT_START{    \
  63.      if (!(expr)) {                            \
  64.          if (opt_ev)                                                    \
  65.          CORBA_exception_set (opt_ev, CORBA_USER_EXCEPTION,         \
  66.                   ex_Bonobo_BadArg, NULL);              \
  67.      g_log (G_LOG_DOMAIN,                        \
  68.         G_LOG_LEVEL_CRITICAL,                    \
  69.         "file %s: line %d (%s): assertion `%s' failed.",    \
  70.         __FILE__,                        \
  71.         __LINE__,                        \
  72.         G_GNUC_PRETTY_FUNCTION,                    \
  73.         #expr);                            \
  74.          return val;                                                    \
  75.      };    }G_STMT_END
  76. #endif
  77.  
  78. #define BONOBO_EX(ev)         ((ev) && (ev)->_major != CORBA_NO_EXCEPTION)
  79.  
  80. #define BONOBO_USER_EX(ev,id) ((ev) && (ev)->_major == CORBA_USER_EXCEPTION &&    \
  81.                    (ev)->_id != NULL && !strcmp ((ev)->_id, id))
  82.  
  83. #define BONOBO_EX_REPOID(ev)  (ev)->_id
  84.  
  85. #define BONOBO_RET_EX(ev)        \
  86.     G_STMT_START{            \
  87.         if (BONOBO_EX (ev))    \
  88.             return;        \
  89.     }G_STMT_END
  90.  
  91. #define BONOBO_RET_VAL_EX(ev,v)        \
  92.     G_STMT_START{            \
  93.         if (BONOBO_EX (ev))    \
  94.             return (v);    \
  95.     }G_STMT_END
  96.  
  97. typedef char *(*BonoboExceptionFn)     (CORBA_Environment *ev, gpointer user_data);
  98.  
  99. char *bonobo_exception_get_text        (CORBA_Environment *ev);
  100. char *bonobo_exception_repoid_to_text  (const char *repo_id);
  101.  
  102.  
  103. void  bonobo_exception_add_handler_str (const char *repo_id,
  104.                     const char *str);
  105.  
  106. void  bonobo_exception_add_handler_fn  (const char *repo_id,
  107.                     BonoboExceptionFn fn,
  108.                     gpointer          user_data,
  109.                     GDestroyNotify    destroy_fn);
  110.  
  111. void  bonobo_exception_general_error_set (CORBA_Environment *ev,
  112.                       CORBA_TypeCode     opt_deriv,
  113.                       const char        *format,
  114.                       ...);
  115.  
  116. const char *bonobo_exception_general_error_get (CORBA_Environment *ev);
  117.  
  118. #endif /* _BONOBO_EXCEPTION_H_ */
  119.